//Controller που ελεγχει την καταχωρηση του καταστηματος
package Controllers;

import DAO.StoreEntry_Dao;
import Exceptions.DaoException;
import Interfaces.IStoreEntry_Dao;
import Models.StoreEntry;
import javax.swing.JOptionPane;

public class StoreEntry_Controller {

    public StoreEntry_Controller() {

    }

    public StoreEntry_Controller(StoreEntry_Dao storeEntry_Dao) {

    }

    public boolean Validate(String StoreName, String Address, String City, String StorePhone, String Floors, String Seats, String Parking, String ParkingSpots, String DaysOpen) throws IllegalArgumentException, DaoException {
        boolean x = true;
        try {
            if (StoreName.isEmpty() || Address.isEmpty() || StorePhone.isEmpty() || Floors.isEmpty() || City.isEmpty() || ParkingSpots.isEmpty() || DaysOpen.isEmpty() || Parking.isEmpty() || Seats.isEmpty()) {
                //JOptionPane.showMessageDialog(null, "There is an empty field.");
                x = false;
            } else if (StorePhone.length() > 10 || StorePhone.length() < 10) {
                //JOptionPane.showMessageDialog(null, "Wrong StorePhone");
                x = false;
            } else if (StorePhone.matches("[0-9]+") == false) {
                //JOptionPane.showMessageDialog(null, "StorePhone must contain digits ONLY");
                x = false;
            } else if (Floors.matches("[0-9]+") == false) {
                //JOptionPane.showMessageDialog(null, "Floors must contain digits ONLY");
                x = false;
            } else if (Seats.startsWith("0") && Seats.endsWith("0")) {
                //JOptionPane.showMessageDialog(null, "Need to have at least 1 Seat");
                x = false;
            } else if (Seats.matches("[0-9]+") == false) {
                //JOptionPane.showMessageDialog(null, "Seats you entered is non-digit, try again");
                x = false;
            } else if (ParkingSpots.matches("[0-9]+") == false) {
                //JOptionPane.showMessageDialog(null, "ParkingSpots you entered is non-digit, try again");
                x = false;
            } else if (StoreName.length() > 25) {
                //JOptionPane.showMessageDialog(null, "Too Big StoreName , Needs to 0-25 chars Long");
                x = false;
            }

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Error");
        }
        return x;

    }
}
